"""
@filename: admin.py
@project: flask_project
@author: wlf
@time: 2022-09-04
学校管理员表
"""
from model import db
import datetime


class Admin(db.Model):
    __tablename__ = "admin"  # 映射的数据库，不写默认是类名
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
    school_id = db.Column(db.Integer, db.ForeignKey("school.id"))
    CreatedAt = db.Column(db.DateTime, default=datetime.datetime.now())

    def to_json1(self):
        return {
            "user_id": self.user_id,
            "school_id": self.school_id,
            "Create time": self.CreatedAt.strftime('%Y-%m-%d %H:%M:%S'),
        }